package com.ioc.conver;

import cn.hutool.core.date.DateUtil;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author cyt
 * @create 2020-08-03 16:08
 */

@Component
public class StringToDate implements Converter<String, Date>, BeanFactoryPostProcessor {

    @Override
    public Date convert(String s) {
        /*   DateUtils.parseDate(source, , "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "HH:mm:ss", "HH:mm");*/
        return DateUtil.parseDate(s);
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
        BeanFactory parentBeanFactory = configurableListableBeanFactory.getParentBeanFactory();
        System.out.println("postProcessBeanFactory  - >>  ");
    }
}
